NodeMCU
Pin Configuration of NodeMCU
#include<ESP8266WiFi.h> const char* ssid = "WiFi-Name"; const char* password = "Password"; const char* host = "www.google.com"; int WIFILED = D1; //====================================== //SETUP FUNCTION //======================================= void setup() { pinMode(WIFILED,OUTPUT); Serial.begin(115200); Serial.printf("Connecting to %s\n", ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(); Serial.print("Connected, IP address: "); Serial.println(WiFi.localIP()); } //====================================== //LOOP FUNCTION //======================================= void loop() { if(WiFi.status() == WL_CONNECTED){ WiFiClient client1; if (client1.connect(host,80)) { client1.stop(); digitalWrite(WIFILED,HIGH); } else{ digitalWrite(WIFILED,LOW); client1.stop(); } } }